﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace Tailoring
{
    public partial class searchdialog : Form
    {
        string searchcri = "";
        string name = "";
        string mobile = "";
        string cnic = "";
        string address = "";
        string city = "";
        public string psearchtype { get { return searchcri; } }
        public string psearchkey { get { return txtskey.Text; } }
        
        public void loaddata(string a)
        {
            string fild = a;
            {
                SqlConnection conn = new SqlConnection();
                conn = programcodes.getConnect();
                SqlCommand cmd = new SqlCommand();
                SqlDataReader reader;
                //string strquery=;
                cmd.CommandText = "SELECT * FROM tblclientinfo where'" + fild +"'='" + txtskey.Text + "'";
                cmd.CommandType = CommandType.Text;
                cmd.Connection = conn;
                if (conn == null && conn.State == ConnectionState.Closed)
                {
                    conn.Open();
                }



                reader = cmd.ExecuteReader();
                // Data is accessible through the DataReader object here.

                conn.Close();
            }
        
        
        
        }

        public searchdialog()
        {
            InitializeComponent();
        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }

        private void searchdialog_Load(object sender, EventArgs e)
        {
            cmbstype.SelectedIndex = 0;
           
                
       
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (cmbstype.Text == "ID")
            {
                
                frmcus cs = new frmcus();
                
                cs.pidkey = psearchkey;
                searchcri = "clientId";
                
                cs.Show();
                cs.MdiParent = this.ParentForm;
                cs.searchloadcri();
                //cs.accountinfo();
                
                
                this.Close();
            }
            if (cmbstype.Text == "Cnic")
            {
               
                frmcus cs = new frmcus();
                cs.pcnickey = psearchkey;
                searchcri = "cnic";
                cs.MdiParent = this.ParentForm;
                cs.searchloadcri();
                cs.Show();
                this.Close();
                
            }
            if (cmbstype.Text == "Name")
            {
                
                frmcus cs = new frmcus();

                cs.pnamekey = psearchkey;
                searchcri = "name";
                cs.MdiParent = this.ParentForm;
                cs.Show();
                cs.searchloadcri();
                
               
                this.Close();
            }
            if (cmbstype.Text == "Mobile")
            {
                
                frmcus cs = new frmcus();
                searchcri = "mobile";
                cs.pmobilekey = psearchkey;
                cs.MdiParent = this.ParentForm;
                cs.Show();
                cs.searchloadcri();
                
                this.Close();
            }
        }

        private void txtcencel_Click(object sender, EventArgs e)
        {
            this.Close();

        }
    }
}
